#**************************************************************************
#*
#* File       : LINK.MK
#* Function   :
#* Application:
#* Programmer : ATL Group
#* Date Coded : 
#* Warnings   :
#*
#* ------------------------------------------------------------------------
#*
#   This build file requires certain environmental variables
#   to have been set, preferably in your autoexec.bat file:
#      SDS  - should be set to the directory containing the SDS files (e.g. c:\SDS71)
#      VFSDK - should be set to the directory containing the SDK tools (e.g. c:\VFSDK)
#      VFDEV - should be set to the directory containing the Foundation library (e.g. c:\VFDEV)
#
#* Copyright (C) 1997, VeriFone Inc. All rights reserved.
#*
#* No part of this software may be used, stored, compiled, reproduced,
#* modified, transcribed, translated, transmitted, or transferred, in
#* any form or by any means whether electronic, mechanical, magnetic,
#* optical, or otherwise, without the express prior written permission
#* of VeriFone, Inc.
#*
#**************************************************************************


# Library Paths

SDKRoot  = $(VFSDK)\$(SDK_VER)
ACTRoot  = $(ACT2000)\$(ACT_VER)
VMACResDir = $(SRC_ROOT)\VMAC

SDKLibraries = $(SDKRoot)\lib
ACTLibraries = $(ACTRoot)\lib
SERFRoot = $(SERF)\$(SERF_VER)

AppModulesLibs =               \
	$(LIB_DIR)\main.a			   \
	$(LIB_DIR)\accum.a			   \
	$(LIB_DIR)\batch.a			   \
	$(LIB_DIR)\card.a			   \
	$(LIB_DIR)\comm.a			   \
	$(LIB_DIR)\common.a 		   \
        $(LIB_DIR)\control.a                \
        $(LIB_DIR)\config.a                \
        $(LIB_DIR)\ISODump.a	   \
	$(LIB_DIR)\Merch.a			   \
	$(LIB_DIR)\Msg.a			   \
	$(LIB_DIR)\pfr.a			   \
	$(LIB_DIR)\PINPad.a 		   \
	$(LIB_DIR)\PIP.a			   \
	$(LIB_DIR)\Print.a			   \
	$(LIB_DIR)\Protocol.a		   \
	$(LIB_DIR)\rcptcmpt.a		   \
	$(LIB_DIR)\retry.a			   \
	$(LIB_DIR)\Rs232Com.a		   \
	$(LIB_DIR)\seccode.a		   \
	$(LIB_DIR)\shift.a			   \
	$(LIB_DIR)\stats.a			   \
	$(LIB_DIR)\UI.a 			   \
	$(LIB_DIR)\Tran.a			   \
	$(LIB_DIR)\Utils.a			   \
	$(LIB_DIR)\VID.a			   \
	$(LIB_DIR)\Ztconfig.a		   \
	$(LIB_DIR)\Ztexpress.a		   \
	$(LIB_DIR)\CommsH.a 		   \
	$(LIB_DIR)\SPUCL.a			   \
##	$(LIB_DIR)\ucl.a  				\
        $(LIB_DIR)\EMVSrc.a   				\
        $(LIB_DIR)\cpacsrc.a                         \
##        $(LIB_DIR)\axapsrc.a                         \
##        $(LIB_DIR)\jcbisrc.a                         \
##        $(LIB_DIR)\dincsrc.a                         \
##        $(LIB_DIR)\bochsrc.a                         \
##        $(LIB_DIR)\cashsrc.a                         \
##       $(LIB_DIR)\cabksrc.a                         \
##       $(LIB_DIR)\eppsrc.a                         \
	$(LIB_DIR)\imam.a                         \
        $(LIB_DIR)\$(SP_PROJ).a   \
	$(LIB_DIR)\$(SP_PROJ)Src.a   \
	$(LIB_DIR)\project.a

FoundationLibs =  \
# Statically link the app, if the application is standalone... Saves about 80k
#$(ACTRoot)\Output\Files\Static\Debug\ACT2000.a  \
# otherwise link it as a shared lib
#$(ACTRoot)\Output\Files\ShLib1\Debug\ACT.slk  \
$(ACTRoot)\Output\RV\Files\Static\Debug\ACT2000.a \
$(SDKRoot)\lib\Verix.lib   \
$(SDKRoot)\lib\Voy.lib  \
$(SERFRoot)\lib\SERFARM.A     \
$(SERFRoot)\lib\serfextraARM.a \
$(SERFRoot)\lib\txoserfARM.a  \
$(TCPIP)\$(TCPIP_VER)\OutPut\RV\Files\Static\Debug\vtcpip.a  \
#$(TCPIP)\$(TCPIP_VER)\OutPut\RV\Files\Static\Debug\vSSL.a  \
$(UCL)\$(UCL_VER)\OutPut\RV\Files\Static\Debug\ucl.a \
$(CARDSLOT)\$(CLS_VER)\Output\RV\Files\static\debug\cardslot.a	\
$(VVXEMVAP)\$(XEMV_VER)\Output\RV\Files\Static\Debug\emv.a	\
$(VVXEMVAP)\$(XEMV_VER)\Output\RV\Files\Static\Debug\emvap_config.a \
$(VVXEMVAP)\$(XEMV_VER)\Output\RV\Files\Static\Debug\vxemvap.a	
#$(CARDSLOT)\$(CLS_VER)\lib\sdsdbg\cardslot.a        \
#$(EMVLIB)\$(EMV_VER)\lib\sdsdbg\emv.a \
#$(EMVLIB)\$(EMV_VER)\lib\sdsdbg\sha\sha.a      \
#$(VXEMVAP)\$(VXEMVAP_VER)\lib\sdsdbg\vxemvap.a
#$(UCL)\library\sdsdbg\ucl.a

# Compiler Options
linkOptions = -xref 
# -entry 8+startup(startupseg)
#-d $(SDKRoot)\lib\_start.o

# LFLAGS = -g -k -vv -map -s 40000 -h 70000
LFLAGS = -g -k -vv -map -s 80000 -h 140000
# LFLAGS = -g -k -vv -map -s 91136 -h 180960

sp2000.out : $(FoundationLibs) $(AppModulesLibs)
  @Echo Running Linker SP2000...
  $(SDKRoot)\bin\vrxcc $(LFLAGS) $(AppModulesLibs)  $(FoundationLibs) $(OBJ_DIR)\appl.o -o $(@)
  @copy sp2000.* $(SPFILES)\*.*
  @del sp2000.*

  \SOFTPAY\VER30\TOOLS\FILESIGN -c $(SDKRoot)\CONFIG\K2SIGN.CRT -k $(SDKRoot)\CONFIG\K2SIGN.KEY -f $(SPFILES)\sp2000.OUT -s $(SPFILES)\sp2000.p7s

  \SOFTPAY\VER30\TOOLS\FILESIGN -c $(SDKRoot)\CONFIG\K2SIGN.CRT -k $(SDKRoot)\CONFIG\K2SIGN.KEY -f $(SPFILES)\sp2000.OUT -s $(SPFILES)\sp2flash.p7s -L

  \SOFTPAY\VER30\TOOLS\FILESIGN -c $(SDKRoot)\CONFIG\K2SIGN.CRT -k $(SDKRoot)\CONFIG\K2SIGN.KEY -f $(SPFILES)\dbmon.OUT -s $(SPFILES)\dbmon.p7s

 \SOFTPAY\VER30\TOOLS\FILESIGN -c $(SDKRoot)\CONFIG\K2SIGN.CRT -k $(SDKRoot)\CONFIG\K2SIGN.KEY -f $(SPFILES)\act.lib -s $(SPFILES)\act.p7s -L
